using ASP;
using HoWave.Common;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public class HL_Admin_Admin_ShopMessage : Admin, IRequiresSessionState
{
	private Shop_Message _Message = null;
	private string m_DroStatus = "";
	private string m_DroType = "";
	private string m_BeginDate = "";
	private string m_EndDate = "";
	protected int m_MaxPerPage = 15;
	protected string WhereStr = "";
	protected string linkhead = "";
	protected bool m_tag = true;
	protected ArrayList al = new ArrayList();
	protected IDbDataParameter[] param;
	protected DropDownList DroStatus;
	protected DropDownList DroType;
	protected TextBox TxtBeginDate;
	protected TextBox TxtEndDate;
	protected Button ImgButSearch;
	protected GridView GVReviewMan;
	protected Label PagePanel;
	protected Shop_Message m_Message
	{
		get
		{
			Shop_Message message;
			if (this._Message == null)
			{
				this._Message = new Shop_Message(this.conn);
				message = this._Message;
			}
			else
			{
				message = this._Message;
			}
			return message;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void SetParam()
	{
		if (this.al.Count > 0)
		{
			this.param = new IDbDataParameter[this.al.Count];
			this.al.CopyTo(this.param, 0);
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(18))
		{
			base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "Message");
			base.WriteRightErrMsg();
		}
		if (!base.IsPostBack)
		{
			this.TxtBeginDate.Attributes.Add("onClick", "SelectDate(" + this.TxtBeginDate.UniqueID + ",'yyyy-MM-dd');");
			this.TxtEndDate.Attributes.Add("onClick", "SelectDate(" + this.TxtEndDate.UniqueID + ",'yyyy-MM-dd');");
			this.BindList();
		}
	}
	protected void BindList()
	{
		int num = Fetch.GetID("page");
		if (num <= 0)
		{
			num = 1;
		}
		this.QuestString();
		this.SetParam();
		if (this.param != null)
		{
			this.GVReviewMan.DataSource = this.m_Message.GetAllMessages(num, this.m_MaxPerPage, this.WhereStr, "", this.param);
		}
		else
		{
			this.GVReviewMan.DataSource = this.m_Message.GetAllMessages(num, this.m_MaxPerPage, this.WhereStr, "");
		}
		this.GVReviewMan.DataBind();
		for (int i = 0; i < this.GVReviewMan.Rows.Count; i++)
		{
			Label label = (Label)this.GVReviewMan.Rows[i].FindControl("lblContent");
			HiddenField hiddenField = (HiddenField)this.GVReviewMan.Rows[i].FindControl("hfContent");
			if (label != null)
			{
				string text = hiddenField.Value;
				int num2 = text.IndexOf("------------------------------------------");
				if (num2 > 0)
				{
					text = text.Substring(0, num2);
					label.Text = text;
				}
			}
		}
		this.PagePanel.Text = this.m_Message.GetPagePanel(this.linkhead);
	}
	protected void QuestString()
	{
		this.m_DroStatus = Fetch.Get("status");
		if (this.m_DroStatus != string.Empty && this.m_tag)
		{
			this.DroStatus.SelectedValue = this.m_DroStatus;
		}
		else
		{
			this.m_DroStatus = this.DroStatus.SelectedValue;
		}
		if (this.m_DroStatus != "")
		{
			if (this.m_DroStatus == "0")
			{
				this.WhereStr += "and M_Status=0 ";
			}
			else
			{
				if (this.m_DroStatus == "1")
				{
					this.WhereStr += "and M_Status=1 ";
				}
			}
			this.linkhead = this.linkhead + "&status=" + this.m_DroStatus;
		}
		this.m_DroType = Fetch.Get("type");
		if (this.m_DroType != string.Empty && this.m_tag)
		{
			this.DroType.SelectedValue = this.m_DroType;
		}
		else
		{
			this.m_DroType = this.DroType.SelectedValue;
		}
		if (this.m_DroType != "-1")
		{
			if (this.m_DroType == "0")
			{
				this.WhereStr += "and M_Type=0 ";
			}
			else
			{
				if (this.m_DroType == "1")
				{
					this.WhereStr += "and M_Type=1 ";
				}
				else
				{
					if (this.m_DroType == "2")
					{
						this.WhereStr += "and M_Type=2 ";
					}
				}
			}
			this.linkhead = this.linkhead + "&type=" + this.m_DroType;
		}
		this.m_BeginDate = Fetch.Get("bt");
		if (this.m_BeginDate != string.Empty && this.m_tag)
		{
			this.TxtBeginDate.Text = this.m_BeginDate;
		}
		else
		{
			this.m_BeginDate = this.TxtBeginDate.Text;
		}
		if (this.m_BeginDate != string.Empty)
		{
			this.WhereStr += "and M_DateTime>@be_DateTime ";
			IDbDataParameter value = this.conn.CreateParameter("@be_DateTime", DbType.DateTime, this.m_BeginDate);
			this.al.Add(value);
			this.linkhead = this.linkhead + "&bt=" + this.m_BeginDate;
		}
		this.m_EndDate = Fetch.Get("et");
		if (this.m_EndDate != string.Empty && this.m_tag)
		{
			this.TxtEndDate.Text = this.m_EndDate;
		}
		else
		{
			this.m_EndDate = this.TxtEndDate.Text;
		}
		if (this.m_EndDate != string.Empty)
		{
			if (this.m_BeginDate != string.Empty)
			{
				if (Convert.ToDateTime(this.m_EndDate) < Convert.ToDateTime(this.m_BeginDate))
				{
					this.WriteErrMsg("", Language.GetAdminMsg("Common/DateTimeErr"), "");
				}
			}
			this.WhereStr += "and M_DateTime<@end_DateTime ";
			IDbDataParameter value = this.conn.CreateParameter("@end_DateTime", DbType.DateTime, this.m_EndDate);
			this.al.Add(value);
			this.linkhead = this.linkhead + "&et=" + this.m_EndDate;
		}
		if (this.WhereStr != string.Empty)
		{
			this.WhereStr = "and" + this.WhereStr;
			this.WhereStr = this.WhereStr.Replace("andand", "where");
		}
	}
	protected void DownList_OnChange(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void TypeDownList_OnChange(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
	protected void GVReviewMan_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (!base.admin.CheckAdminPower(18))
		{
			base.WriteRightErrMsg();
		}
		this.m_Message.DeleteMessage(int.Parse(this.GVReviewMan.SelectedRow.Cells[0].Text));
		this.m_tag = false;
		this.BindList();
	}
	protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
	{
		if (e.Row.RowType == DataControlRowType.DataRow)
		{
			e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#E7EDFE'");
			e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
			if (e.Row.Cells[5].Text == "True")
			{
				e.Row.Cells[5].Text = Language.GetAdminMsg("ShopMessage/Status/Status1");
			}
			else
			{
				e.Row.Cells[5].Text = Language.GetAdminMsg("ShopMessage/Status/Status0");
			}
			string text = e.Row.Cells[2].Text;
			if (text != null)
			{
				if (text == "0")
				{
					e.Row.Cells[2].Text = Language.GetAdminMsg("ShopMessage/Type/Type0");
					goto IL_1AF;
				}
				if (text == "1")
				{
					e.Row.Cells[2].Text = Language.GetAdminMsg("ShopMessage/Type/Type1");
					goto IL_1AF;
				}
				if (text == "2")
				{
					e.Row.Cells[2].Text = Language.GetAdminMsg("ShopMessage/Type/Type2");
					goto IL_1AF;
				}
			}
			e.Row.Cells[2].Text = Language.GetAdminMsg("ShopMessage/Type/Type0");
			IL_1AF:;
		}
	}
	protected void ImgButSearch_Click(object sender, EventArgs e)
	{
		this.m_tag = false;
		this.BindList();
	}
}
